﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GenerateAdminPage.Classes.Base
{
    #region USING
    using GenerateAdminPage.Classes.Models;
    using GenerateAdminPage.Classes.Helpers;
    using GenerateAdminPage.Classes.DBStructure;
    #endregion

    public enum GenerateType
    {
        SINGLE,
        COMPLEX,
        ONE_TO_MANY,
        SELECT_MANY_FOR_ONE
    }

    /// <summary>
    /// Abstract base class: implement some inheritance methods and some mothod to child classes overritance
    /// </summary>
    public abstract class AbstractBase: IBase
    {
        #region CONSTANTS
        public string END = Environment.NewLine;
        public const string TAB  = "\t";
        public const string TAB2 = "\t\t";
        public const string TAB3 = "\t\t\t";
        public const string TAB4 = "\t\t\t\t";
        public const string TAB5 = "\t\t\t\t\t";
        public const string TAB6 = "\t\t\t\t\t\t";
        public const string TAB7 = "\t\t\t\t\t\t\t";
        public const string TAB8 = "\t\t\t\t\t\t\t\t";
        public const string TAB9 = "\t\t\t\t\t\t\t\t\t";
        #endregion

        #region PROPERTIES
        public DataBase DB { get; set; }
        public Table TblOne { get; set; }
        public Table TblMany { get; set; }
        #endregion

        #region METHODS
        public void InitClassGenerate(DataBase db, Table tblOne, Table tblMany)
        {
            DB = db;
            TblOne = tblOne;
            TblMany = tblMany;
        }

        public virtual string GenerateNameSpace(string nameSpace)
        {
            StringBuilder Result = new StringBuilder();
            Result.AppendLine("using System;");
            Result.AppendLine("using System.Collections.Generic;");
            Result.AppendLine("using System.Linq;");
            Result.AppendLine("using System.Windows.Forms;");
            Result.AppendLine("namespace " + GlobalVariables.g_sNameSpace + "." + nameSpace);
            Result.AppendLine("{");
            Result.AppendLine(GenerateUsingRegion());
            Result.AppendLine(GenerateClass());
            Result.AppendLine("}");
            return Result.ToString();
        }

        /// <summary>
        /// Method is overrided by child classes
        /// </summary>
        /// <returns>Return a string that present using region</returns>
        public abstract string GenerateUsingRegion();

        /// <summary>
        /// Method is overrided by child classes
        /// </summary>
        /// <returns>Return a string that present body of class</returns>
        public abstract string GenerateClass();
        #endregion
    }
}
